var t, o = require("../../../@babel/runtime/helpers/interopRequireDefault"), n = require("../../../@babel/runtime/helpers/defineProperty"), e = o(require("../../../dist/dialog/dialog")), a = getApp(), i = require("../../../mybehaviors/location/location");

Page((n(t = {
    behaviors: [ i ],
    data: {
        cstoreId: null,
        authType: 0,
        timeType: "",
        longitude: "",
        latitude: "",
        groupList: {},
        storeInfo: {},
        storeList: [],
        slideBanner: [],
        distanceInex: 2,
        distance: 3,
        distanceItem: 1,
        distanceList: [ 1, 2, 3, 4, 5 ],
        authTypeName: "",
        distanceShow: !1,
        businessShow: !1,
        couponShow: !1,
        couponText: "",
        couponSn: "",
        shopList: [ {
            text: "扫码验券",
            img: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/consumption-coupons/shop1.png",
            navTo: "couponCode"
        }, {
            text: "输码验券",
            img: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/consumption-coupons/shop2.png",
            navTo: "couponShow"
        }, {
            text: "核销明细",
            img: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/consumption-coupons/shop3.png",
            navTo: "/packageF/consumption/verificationDetails/verificationDetails"
        }, {
            text: "商品管理",
            img: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/consumption-coupons/shop4.png",
            navTo: "/packageF/consumption/commodity/commodity"
        }, {
            text: "售卖明细",
            img: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/consumption-coupons/shop5.png",
            navTo: "/packageF/consumption/sellDetail/sellDetail"
        }, {
            text: "客户评价",
            img: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/consumption-coupons/shop6.png",
            navTo: "/packageF/consumption/clientEvaluation/clientEvaluation"
        }, {
            text: "核销员管理",
            img: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/consumption-coupons/shop7.png",
            navTo: "/packageF/consumption/verifierList/verifierList"
        }, {
            text: "收益管理",
            img: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/consumption-coupons/shop8.png",
            navTo: "/packageF/consumption/incomeDetail/incomeDetail"
        } ],
        shopVerifierList: [ {
            text: "扫码验券",
            img: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/consumption-coupons/shop1.png",
            navTo: "couponCode"
        }, {
            text: "输码验券",
            img: "https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/consumption-coupons/shop2.png",
            navTo: "couponShow"
        } ],
        statsList: [ {
            price: 3,
            text: "核销订单数",
            code: ""
        }, {
            price: 0,
            text: "待核销订单数",
            code: ""
        }, {
            price: 0,
            text: "支付订单数",
            code: ""
        }, {
            price: 0,
            text: "退款订单数",
            code: ""
        }, {
            price: 0,
            text: "会员人数",
            code: ""
        }, {
            price: 0,
            text: "在售商品数",
            code: ""
        } ]
    },
    onLoad: function(t) {
        var o = this;
        try {
            wx.removeStorageSync("applyaddresspoint");
        } catch (t) {}
        this._getLocation(function(n, e) {
            var a;
            o.setData({
                longitude: e.lng,
                latitude: e.lat
            }), "" !== (null !== (a = t.cstoreId) && void 0 !== a ? a : "") && o.setData({
                cstoreId: Number(t.cstoreId)
            }), o.businessData();
        }, function(t) {
            console.log(t), wx.showToast({
                icon: "none",
                title: "请开启定位授权",
                duration: 1500
            }), setTimeout(function() {
                wx.navigateBack({
                    delta: 1
                });
            }, 1e3);
        });
    },
    onShow: function() {
        try {
            var t = wx.getStorageSync("applyaddresspoint");
            t && this.setData({
                longitude: t.point.lng,
                latitude: t.point.lat
            });
        } catch (t) {
            console.log(t);
        }
    },
    businessData: function() {
        var t = this, o = a.getNetAddresss("plugin.coupon-store.frontend.store-manage.index"), n = {
            cstore_id: this.data.cstoreId,
            distance: this.data.distance,
            longitude: this.data.longitude,
            latitude: this.data.latitude,
            time_type: this.data.timeType
        };
        a._postNetWork({
            url: o,
            data: n,
            success: function(o) {
                var n = o.data;
                if (1 == n.result) {
                    var e = n.data.count, a = t.data.statsList;
                    Object.keys(e).forEach(function(t, o) {
                        a[o].code = t, a[o].price = e[t];
                    }), t.setData({
                        statsList: a,
                        authTypeName: n.data.auth_type_name,
                        authType: n.data.auth_type,
                        slideBanner: n.data.slide,
                        groupList: n.data.group_list,
                        storeList: n.data.store_list,
                        cstoreId: n.data.store.id,
                        storeInfo: n.data.store
                    });
                } else wx.showToast({
                    icon: "none",
                    title: n.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    onClose: function(t) {
        var o = t.currentTarget.dataset.type;
        "distance" === o ? this.setData({
            distanceShow: !1
        }) : "couponCode" === o ? this.setData({
            couponShow: !1
        }) : this.setData({
            businessShow: !1
        });
    },
    onOpen: function(t) {
        var o = t.currentTarget.dataset.type;
        "distance" === o ? this.setData({
            distanceShow: !0
        }) : "couponCode" === o ? this.setData({
            couponShow: !1
        }) : this.setData({
            businessShow: !0
        });
    },
    bindCoupon: function(t) {
        this.setData({
            couponText: t.detail.value
        });
    },
    onAffirm: function() {
        this.setData({
            distanceShow: !1,
            distance: this.data.distanceItem
        }), this.businessData();
    },
    onCouponAffirm: function() {
        var t = this;
        this.data.couponText ? (this.setData({
            couponSn: this.data.couponText
        }), e.default.confirm({
            title: "提示",
            message: "是否确认核销消费券号：".concat(this.data.couponSn)
        }).then(function() {
            var o = t, n = a.getNetAddresss("plugin.coupon-store.frontend.store-manage.examineCoupon"), i = {
                cstore_id: t.data.cstoreId,
                coupon_sn: t.data.couponSn,
                request_type: 2
            };
            a._postNetWork({
                url: n,
                data: i,
                success: function(t) {
                    var n = t.data;
                    1 == n.result ? (wx.showToast({
                        icon: "none",
                        title: n.msg,
                        duration: 1500
                    }), o.setData({
                        couponShow: !1,
                        couponText: ""
                    })) : e.default.alert({
                        title: "提示",
                        message: n.msg
                    }).then(function() {});
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }).catch(function() {})) : wx.showToast({
            icon: "none",
            title: "请输入消费券编码",
            duration: 1500
        });
    },
    onActiveStore: function(t) {
        var o = t.currentTarget.dataset.id;
        wx.redirectTo({
            url: "/packageF/consumption/business/business?cstoreId=".concat(o)
        });
    },
    onDistance: function(t) {
        var o = t.currentTarget.dataset, n = o.index, e = o.item;
        this.setData({
            distanceInex: n,
            distanceItem: e
        });
    },
    slideNavTo: function(t) {
        var o = t.currentTarget.dataset.navto;
        wx.navigateTo({
            url: o
        });
    },
    timeBusiness: function(t) {
        var o = t.currentTarget.dataset.timetype;
        this.data.timeType !== o && (this.setData({
            timeType: o
        }), this.businessData());
    },
    shopItemOn: function(t) {
        var o = this, n = t.currentTarget.dataset.navto;
        "couponShow" === n ? this.setData({
            couponShow: !0
        }) : "couponCode" === n ? wx.scanCode({
            success: function(t) {
                wx.navigateTo({
                    url: "/packageF/consumption/verification/verification?storeId=".concat(o.data.cstoreId, "&couponSn=").concat(t.result)
                });
            }
        }) : wx.navigateTo({
            url: "".concat(n, "?storeId=").concat(this.data.cstoreId)
        });
    },
    onReady: function() {}
}, "onShow", function() {}), n(t, "onHide", function() {}), n(t, "onUnload", function() {}), 
n(t, "onPullDownRefresh", function() {}), n(t, "onReachBottom", function() {}), 
n(t, "onShareAppMessage", function() {}), t));